Conversation
5119783 to
4941d68
Compare
npry
left a comment
There was a problem hiding this comment.
Directionally I'm on board, I think the current shape has some awkwardness around the specific composition of structs and enums (mostly in ts_control). The main hangup is that I'm not sure why we're nesting enum-in-enum there. As I mention in one of my comments, it feels to me like it wants to be a struct Error with a flat ErrorKind enum, so I'm curious why you laid it out that way
Yeah, a few places did feel pretty awkward and I definitely think this can be improved.
So the idea here is that the top-level variants for each variant reflect possible recovery strategies - e.g., in ts_control, This could all be better documented! And some of the names can definitely be improved. Hopefully that makes sense why there are nested enums and not a struct. |
|
Latest commit makes some of the suggested changes. I haven't updated docs to correspond or applied suggestions which I'd like to discuss further. |
Signed-off-by: Nick Cameron <nrc@ncameron.org>
Signed-off-by: Nick Cameron <nrc@ncameron.org>
Signed-off-by: Nick Cameron <nrc@ncameron.org>
|
Updated the PR following our chat last week. The changes are in a separate commit. I think I got everything we discussed (and comments here), but let me know if I missed anything. I'm much happier with the new errors. There is one question inline (marked There is also one question in a reply above because of my bad memory. |
4ed2420 to
afcf59f
Compare
There was a problem hiding this comment.
bunch of small nits, but the blocker is that imo NetworkError in its various incarnations probably want to split along the lines of issues <= L4 and > L4, i.e. is the network itself down, or is this a higher-layer problem? the former can be handled by retries or possibly out-of-band online checks, where an http 400 or a tls negotiation failure can't be resolved the same way (not retryable). probably this latter case can be handled as an Internal variant for now?
edit: otherwise, lgtm!
Signed-off-by: Nick Cameron <nrc@ncameron.org>
|
@npry all comments addressed. Thank you for helping me iterate on this! |
npry
left a comment
There was a problem hiding this comment.
github was having a fit when i was giving this a look yesterday, sorry for the delay
want to make sure we didn't get wires crossed about the NetworkError point -- i assume my comments here are just instances i didn't directly comment on, so you didn't update, rather than a disagreement about the concept? lmk if not, but lgtm assuming these are resolved
| impl From<ts_http_util::Error> for RegistrationError { | ||
| fn from(error: ts_http_util::Error) -> Self { | ||
| tracing::error!(%error, "http error sending registration request"); | ||
| RegistrationError::NetworkError | ||
| } |
There was a problem hiding this comment.
should only be network error if io? (which is unfortunately currently undifferentiated within ts_http_util)
| tracing::error!(%body, %status, "registration failed"); | ||
|
|
||
| return Err(RegistrationError::RegistrationFailed(status.as_u16())); | ||
| return Err(RegistrationError::NetworkError); |
There was a problem hiding this comment.
this is pretty specifically an http error (status code) / not network
| #[error("error during registration: {0}")] | ||
| Internal(InternalErrorKind), | ||
| #[error("HTTP error")] | ||
| NetworkError, |
There was a problem hiding this comment.
based on usage below i think this wants to be http error? or reconcile the #[error] message
| #[error("invalid URL: {0}")] | ||
| InvalidUrl(url::Url), | ||
|
|
||
| /// Some kind of networking error, e.g., HTTP, TLS. |
There was a problem hiding this comment.
specifically not http or tls?
| impl From<ts_http_util::Error> for Error { | ||
| fn from(error: ts_http_util::Error) -> Self { | ||
| tracing::error!(%error, "http error"); | ||
| Error::NetworkError(Operation::ConnectToControlServer) |
There was a problem hiding this comment.
? http shouldn't be NetworkError unless it's ts_http_util::Error::Io
| let port = url | ||
| .port_or_known_default() | ||
| .ok_or(ConnectionError::ConnectionFailed)?; | ||
| .ok_or(Error::InvalidUrl(url.clone()))?; |
There was a problem hiding this comment.
nit: ok_or_else to skip the clone on the happy path
| "https" => { | ||
| let conn = ts_tls_util::connect( | ||
| ts_tls_util::server_name(url).ok_or(ConnectionError::ConnectionFailed)?, | ||
| ts_tls_util::server_name(url).ok_or(Error::InvalidUrl(url.clone()))?, |
| MissingPayload, | ||
| #[error(transparent)] | ||
| WatchRecv(#[from] watch::error::RecvError), | ||
| #[error("HTTP error")] |
| tracing::error!(%error, "Error parsing HTTP request"); | ||
| PingError::NetworkError |
There was a problem hiding this comment.
which do you mean? this is inconsistent -- http parse wouldn't be a network error, and this From is also invoked for the http2 post, which could be L3 interruption or L7 failure
An attempt at refactoring some of our errors into a more handling-oriented approach. I'm a bit unsure about some of the names, descriptions, and categorisations, so feedback on that stuff in particular (as well as the rest of the approach) would be welcome!